﻿<?php include $this->admin_tpl('meta');?>
<title>商品列表</title>
<script type="text/javascript" src="<?php echo STATIC_URL;?>plugin/jquery/1.8.2/jquery.min.js"></script>
</head>
<body>
<div class="page-container" style="padding-bottom:0;">
	<form id="search">
		<input type="hidden" value="" name="field">
		<input type="hidden" value="" name="order">
		<input type="hidden" value="0" name="download">
		<div class="c"><input type="text" name="po_id" class="input-text" style="width:130px" placeholder="采购单号" value="<?php if(isset($_GET['po_id'])) echo $_GET['po_id'];?>"></div>
		<div class="c"><input type="text" name="i_id" class="input-text" style="width:130px" placeholder="款式编码,*号开头模糊匹配" value="<?php if(isset($_GET['i_id'])) echo $_GET['i_id'];?>"></div>
		<div class="c"><input type="text" name="sku_id" class="input-text" style="width:130px" placeholder="商品编码,*号开头模糊匹配" value="<?php if(isset($_GET['sku_id'])) echo $_GET['sku_id'];?>"></div>
		<div class="c"><input type="text" name="name" class="input-text" style="width:130px" placeholder="商品名称" value="<?php if(isset($_GET['name'])) echo $_GET['name'];?>"></div>
		<div class="c"><input type="text" name="other_2" class="input-text" style="width:130px" placeholder="其他属性2" value="<?php if(isset($_GET['other_2'])) echo $_GET['other_2'];?>"></div>
		<div class="select-box inline c">
		<select name="status" class="select">
			<option value="" <?php if($status==''){?> selected <?php }?>>状态</option>
			<option value="Creating" <?php if($status=='Creating'){?> selected <?php }?>>草拟</option>
			<option value="WaitConfirm" <?php if($status=='WaitConfirm'){?> selected <?php }?>>待审核</option>
			<option value="Confirmed" <?php if($status=='Confirmed'){?> selected <?php }?>>已确认</option>
			<option value="Finished" <?php if($status=='Finished'){?> selected <?php }?>>完成</option>
			<option value="Cancelled" <?php if($status=='Cancelled'){?> selected <?php }?>>作废</option>
		</select>
		</div>
		<div class="select-box inline c">
		<select name="jst_id" class="select">
			<option value="" <?php if($jst_id==''){?> selected <?php }?>>请选择聚水潭</option>
			<option value="1" <?php if($jst_id==1){?> selected <?php }?>>佑晟</option>
			<option value="2" <?php if($jst_id==2){?> selected <?php }?>>JEEP(旧)</option>
			<option value="6" <?php if($jst_id==6){?> selected <?php }?>>JEEP</option>
		</select>
		</div>
		<a class="btn btn-success radius" href="javascript:void(0)" id="btn_search"><i class="yzm-iconfont yzm-iconsousuo"></i> 搜索</a>
		<button class="btn btn-primary radius" id="btn_reset" type="reset"><i class="yzm-iconfont yzm-iconshuaxin"></i> 重置</button>
		<button name="dosubmit" class="btn btn-warning radius hidden-xs" type="button" id="btn_download" url="<?php echo U('purchaser');?>"><i class="yzm-iconfont yzm-iconxiazai"> 导出</i></button>
	</form>
	<table id="table" class="mt-20" lay-filter="table" style="font-size:12px;"></table>
</div>
<script type="text/html" id="tool_temp">
	<a href="javascript:;" onclick="yzm_open('添加店铺','<?php echo U('sku_list',['type'=>'reget']);?>','600','480')" class="btn btn-primary radius"><i class="yzm-iconfont yzm-iconshuaxin"></i> 重新获取</a>
	<a href="javascript:;" id="btn_del" class="btn btn-danger radius"><i class="yzm-iconfont yzm-iconshanchu2"></i> 批量删除</a>
</script>
<script type="text/html" id="op_temp">
	<a class="layui-btn layui-btn-yzm layui-btn-xs" onclick="yzm_open('入库记录','<?php echo U('purchaser_log');?>?po_id={{= d.po_id}}&jst_id={{= d.jst_id}}','800','600')" lay-event="detail" style="text-decoration:none;">入库记录</a>
	<a class="layui-btn layui-btn-warm layui-btn-xs" onclick="yzm_open('商品明细','<?php echo U('purchaser_item');?>?po_id={{= d.po_id}}&jst_id={{= d.jst_id}}','800','600')" style="text-decoration:none;">商品明细</a>
</script>
<?php include $this->admin_tpl('jst_common/common_tpl');?>
<?php include $this->admin_tpl('footer');?>
<script type="text/javascript" src="<?php echo STATIC_URL;?>plugin/layui/layui.js"></script>
<script type="text/javascript">
var db = 'jst_purchaser';
layui.use(function(){ //亦可加载特定模块：layui.use(['layer', 'laydate', function(){
	table = layui.table; //表格
	util = layui.util; //工具集
	dropdown = layui.dropdown; //下拉菜单
	form = layui.form;
	//var index = layer.load(1);
	//执行一个 table 实例
	option = {
		elem: '#table',
		id:'table',
		height: 'full-80',
		limit:30,
		limits:[30,60,90],
		url:'<?php echo U('purchaser');?>',
		where: $('#search').serializeJson(),
		title: '商品列表',
		autoSort: false,
		method:'post',
		totalRow: true, // 开启合计行
		page: {theme:'#409eff',groups:3,hash:true}, //开启分页
		toolbar: '#tool_temp', //开启工具栏，此处显示默认图标，可以自定义模板，详见文档
		cols: [[ //表头
			{type: 'checkbox',width:40},
			{field: 'po_id', title: '采购单号', width:80,align:'center'},
			{field: 'name', title: '商品名称',align:'left',width:150},
			{field: 'other_2',title: '颜色',align:'center',width:80,templet:function(row){
				if(!row.other_2){
					return '';
				}
				var temp = row.other_2.split('#');
				temp = temp[1].split('-');
				return temp[0];
			}},
			{field: 'status', title: '状态', width:80,align:'center',templet: function(row){
				var c='';
				var t=''
				switch (row.status) {
					case 'Creating':
						c = 'label-default';
						t = '草拟';
						break;
					case 'WaitConfirm':
						c = 'label-default';
						t = '待审核';
						break;
					case 'Confirmed':
						c= 'label-success';
						t = '已确认';
						break;
					case 'Finished':
						c = 'label-primary';
						t = '已完成';
						break;
					case 'Cancelled':
						c = 'label-danger';
						t = '已作废';
						break;
					default:
						c = 'label-default';
						t = '未知';
					}
				return '<span class="label '+c+' radius">'+t+'</span>';
			},totalRow:'小计'},
			{field: 'qty', title: '采购数量', width:80,align:'center',totalRow:true,totalRowDecimals:0},
			{field: 'act_qty', title: '回货数量', width:80,align:'center',totalRow:true,totalRowDecimals:0},
			{field: 'confirm_date', title: '生效时间',width:100,align:'center',templet: function(row) {return util.toDateString(row.confirm_date*1000, 'MM-dd HH:mm:ss');}},
			{field: 'remark', title: '采购单备注',align:'left',width:150},
			{field: 'back_remark', title: '跟单记录',align:'left',edit:true},
			{field: 'jst_name', title: '聚水潭', width:60,align:'center'},
			{field: 'modified', title: '修改时间',align:'center',width:110,sort:true,templet: function(row) {return util.toDateString(row.modified*1000, 'yy-MM-dd HH:mm:ss');}},
			{field: 'finish_time', title: '完成时间',align:'center',width:110,sort:true,templet: function(row) {
					if(row.finish_time){return util.toDateString(row.finish_time*1000, 'MM-dd HH:mm');}else{
						return '-';
					}
				}
			},
			{field: 'toolbar',fixed: 'right', title: '操作', width: 200, align:'center', toolbar: '#op_temp',}
		]],
		done:function(res,curr,count){
			var options = this;
			//layer.close(index);
			public_table(db);
			select_table(options,<?php echo json_encode($this->jst_arr);?>,'.dropdown-jst',db,'jst_id');
		}
	};
	table.render(option);
	table.hideCol('table', {
	  field: 'id', // 对应表头的 field 属性值
	  hide: true // `true` or `false`
	});
	if($(window).width()<1000){
		table.hideCol('table', {
		  field: 'toolbar', // 对应表头的 field 属性值
		  hide: true // `true` or `false`
		});
	}
	table.hideCol('table', {
	  field: 'sku_code', // 对应表头的 field 属性值
	  hide: true // `true` or `false`
	});
	init_table(db);
})
</script>
</body>
</html>